package core.util;

class MatchHelper {

	public static <T> boolean match(T obj, Matcher<T>[] matchers, boolean isMatchAll) {
		if (ArrayUtil.isEmpty(matchers)) {
			return false;
		}
		
		boolean isMatched = false;
		for (Matcher<T> matcher : matchers) {
			if (matcher == null) {
				continue;
			}

			isMatched = matcher.matches(obj);
			if (isMatched) {
				if (!isMatchAll) {
					return true;
				}
			} else if (isMatchAll) {
				return false;
			}
		}
		
		return isMatched;
	}
}
